package com.sinaapp.mspring.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.sinaapp.mspring.annotation.SystemControllerLog;
import com.sinaapp.mspring.model.pojo.Population;
import com.sinaapp.mspring.service.PopulationServiceI;
import com.sinaapp.mspring.service.TmallMobileServiceI;
import com.sinaapp.mspring.model.vo.TMobile;

/**
 * 可视化
 * @author binchao
 * 2016年2月28日
 */
@Controller
@RequestMapping("/vis")
public class VisController {
	
	
	//视图根目录
	private static final String rootPath = "/vis/";
	
	@Autowired
	private PopulationServiceI popService;
	
	@Autowired
	private TmallMobileServiceI tmallService;
	
	/**
	 * 可视化首页
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "", method = RequestMethod.GET)
	@SystemControllerLog(description = "可视化首页")
	public ModelAndView resume(Model model) {
		
		ModelAndView view = new ModelAndView(rootPath + "index");
		List<Population> populations = popService.selectAll();
		String popOptionJson = popService.getPopulationForEchartsOption();
		String tmallMobile = tmallService.selectWordCloud();
		List<TMobile> top10 = tmallService.selectTop10();
		
		model.addAttribute("populations", populations);
		model.addAttribute("popOptionJson", popOptionJson);
		model.addAttribute("tmallMobile", tmallMobile);
		model.addAttribute("top10", top10);
		return view;
	}

}
